home *** CD-ROM | disk | FTP | other *** search
- #include "defines.h"
- #include "includes.h"
- #include "funcs.h"
-
- void showit(char *string) {
- FILE *display;
- #ifdef DEBUG
- printf ("in showit %s\n",string);fflush(stdout);
- #endif
- display=fopen(FUTABASERIAL,"w");
- fprintf (display, "%s", string);
- fclose (display);
- return;
- }
-
- void specialeffect(int effect) {
- int x;
- int y;
- #ifdef DEBUG
- printf ("in specialeffect\n");fflush(stdout);
- #endif
- for (x=1;x<=1;++x) {
- for (y=1;y<=32;++y) showit ("\177");
- for (y=1;y<=32;++y) showit ("\040");
- }
- return;
- }
-
- int putline(char *inputline, char *position, int direction, char *slot) {
- int length;
- char *end;
- char *displayline;
- #ifdef DEBUG
- printf ("in putline\n");fflush(stdout);
- #endif
-
- displayline=malloc(17);
- memset(displayline,0,17);
-
- length=strlen(inputline);
- end=inputline+length;
- showit("\002");
- showit(slot);
- strncpy(displayline,position,16);
- showit(displayline);
- fflush(stdout);
- if (
- ( ((end-position)<=16) && direction==1)
- ||
- ( (position<=inputline) && direction==0)
- ) return (-1);
- return (0);
- }
-
- int stringpad(char *destination, char *source){
- int retval;
-
- retval=0;
-
- memset(destination,0,1024);
- if (strlen(source) < 16) {
- strncpy(destination," ",16-strlen(source));
- strncat(destination,source,strlen(source));
- strncat(destination," ",16-strlen(source));
- retval=0;
- } else
- if (strlen(source) >= 16) {
- strncpy (destination,source,strlen(source));
- retval=0;
- } else
- if (strlen(source) == 16) {
- retval=-1;
- }
- return (retval);
- }
-
- char *wheretostart(char *pointer,int direction){
- if (direction==-1) return(pointer);
- else return(pointer+1);
- }
-
- void futaba(char *songname, int secint)
- {
-
- time_t timey;
- time_t prevtime;
-
- char *toppos;
- char *botpos;
-
- char *timerem;
-
- char *topline;
- char *botline;
- char *seconds;
-
- int topdir;
- int botdir;
- int topskip=0;
- /* int botskip=0; */
-
- long minute;
- long hour;
- long second;
- long secrem;
-
- secrem=(long)secint;
-
- seconds=calloc(1,10);
-
- timerem=calloc(1,80);
-
- topline=calloc(1,1024);
- botline=calloc(1,1024);
-
- time(&timey);
- prevtime=0;
-
- memset(timerem,0,80);
- memset(topline,0,1024);
- memset(botline,0,1024);
-
-
- botdir=stringpad(botline,songname);
- botpos=wheretostart(botline,botdir);
-
- for (secrem=(long)secint;secrem>0;)
- {
- time(&timey);
- if (prevtime!=timey)
- {
- prevtime = timey ;
- --secrem ;
- hour = secrem / 3600 ;
- minute = secrem / 60 ;
- second = secrem % 60 ;
-
- sprintf (timerem,"Remain: %.2ld:%.2ld:%.2ld",hour,minute,second);
- topskip=0;
- }
- topdir=stringpad(topline,timerem);
- toppos=wheretostart(topline,topdir);
-
- /* usleep (10000); */
- if (topskip==0) {
- if (topdir==1) {
- if (putline(topline,++toppos,topdir,"\001")==-1) {
- topdir=1-topdir;
- }
- } else if (topdir==0) {
- if (putline(topline,--toppos,topdir,"\001")==-1) {
- topdir=1-topdir;
- }
- }
- if (topdir==-1) {
- putline(topline,toppos,-1,"\001");
- }
- }
- topskip=1;
-
- if (botdir==1) {
- if (putline(botline,++botpos,botdir,"\021")==-1)
- botdir=1-botdir;
- } else if (botdir==0) {
- if (putline(botline,--botpos,botdir,"\021")==-1)
- botdir=1-botdir;
- }
- if (botdir==-1) {
- putline(botline,botpos,botdir,"\021");
- }
- usleep(50000);
- }
- specialeffect(0);
- };
-
-